package cn.edu.qzuie.artist.module.td.dal.mysql.region;

import java.util.*;

import cn.edu.qzuie.artist.framework.common.pojo.PageResult;
import cn.edu.qzuie.artist.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.edu.qzuie.artist.framework.mybatis.core.mapper.BaseMapperX;
import cn.edu.qzuie.artist.module.td.dal.dataobject.region.RegionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.edu.qzuie.artist.module.td.controller.admin.region.vo.*;

/**
 * 地域 Mapper
 *
 * @author 泉信管理员
 */
@Mapper
public interface RegionMapper extends BaseMapperX<RegionDO> {

    default List<RegionDO> selectList(RegionListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RegionDO>()
                .likeIfPresent(RegionDO::getName, reqVO.getName())
                .eqIfPresent(RegionDO::getParentId, reqVO.getParentId())
                .eqIfPresent(RegionDO::getLevel, reqVO.getLevel())
                .betweenIfPresent(RegionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RegionDO::getId));
    }

	default RegionDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(RegionDO::getParentId, parentId, RegionDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(RegionDO::getParentId, parentId);
    }

}